module.exports = class extends think.Model {
  async getList() {
    return this.order(`init_time ASC`).select();
  }

  async getPage({ pageNum, pageSize, ...where }) {
    return this.where(where).order(`init_time ASC`).page(pageNum, pageSize).countSelect();
  }

  async create(data) {
    const it = await this.add(data);
    return it;
  }

  async update({ id, ...data }) {
    const it = await this.where({ id }).update(data);
    return it;
  }

  async remove(id) {
    await this.where({ id }).delete();
  }

  async info(id) {
    const it = await this.where({ id }).find();
    return it;
  }

  async getLast() {
    return this.order(`init_time DESC`).page(1, 1).select();
  }
};
